Skip to content

Conversation

@deanlee
Copy link
Contributor

@deanlee deanlee commented Nov 21, 2025

This PR speeds up matrix computation in mici/AugmentedRoadView by improving caching in _calc_frame_matrix.

Performance Impact

mici/AugmentedRoadView/_calc_frame_matrix was a top-10 CPU hotspot in profile_onroad.py
By using cache keys and avoiding redundant numpy calculations, the function now runs about 4× faster.

Metric Before PR After PR Change
tottime $0.125 \text{ s}$ $0.031 \text{ s}$ -75.2%
cumtime $0.253 \text{ s}$ $0.054 \text{ s}$ -78.6%

@github-actions github-actions bot added the ui label Nov 21, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 21, 2025

raylib UI Preview

All Screenshots

@sshane
Copy link
Contributor

sshane commented Nov 27, 2025

In normal driving, does this go from running at 20Hz to something like maybe 5Hz depending on acceleration? How big is the matrix, should we store multiple matrices to avoid recomputation?

@deanlee
Copy link
Contributor Author

deanlee commented Nov 27, 2025

In normal driving, does this go from running at 20Hz to something like maybe 5Hz depending on acceleration?

Yes — that’s why the profile shows about a 4× speedup (20 Hz → ~5 Hz).

should we store multiple matrices to avoid recomputation?

maybe, but it adds complexity. The current cache is good enough for now.

@sshane sshane merged commit 1052435 into commaai:master Nov 27, 2025
15 checks passed
@deanlee deanlee deleted the ui-optimize-frame-matrix branch November 27, 2025 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants